<?php

namespace app\index\controller;

use app\common\controller\Frontend;
use app\common\library\Token;

class Ptzsb extends Frontend
{
    protected $noNeedLogin = '*';
    protected $noNeedRight = '*';
    protected $layout = '';

    public function _initialize()
    {
        parent::_initialize();
    }
    
    public function index(){    
		$list = $this->list;   //目录   
		//dump($list);
		$list1=$list[0]['child'];
    	
    	/* //推荐阅读  //获取当前页面的第一篇文章
    	$map['category_id'] = $list[0]['child'][0]['id'];    	
		$recommend = model('Article')->getArticleListBycategoryId($map,1);
		dump($recommend);
    	if(empty($recommend)){
    		$recommend['title'] = '';
    		$recommend['image'] = '';
    	}else{
    		$recommend = $recommend[0] ;
    	}
    	$this->assign('recommend',$recommend); 
    	//$this->assign('recommend',$recommend[0]);
    	
    	//普通专升本论坛交流
    	$map1['category_id'] = $list[0]['child'][1]['id'];
		$ordinary = model('Article')->getArticleListBycategoryId($map1,9);
		dump($ordinary);
    	foreach ($ordinary as  $key=>$vo){    	    	
    		$ordinary[$key]['title']=my_substr($vo['title'],25);
    	}
    	$this->assign('ordinary',$ordinary);   	
    	
    	//政策信息  前面
    	$map2['category_id'] = $list[0]['child'][4]['id'];
    	$policy = model('Article')->getArticleListBycategoryId($map2,2);    	
    	foreach ($policy as  $key=>$vo){
    		$noticecontent = strip_tags($vo['content']);
    		$policy[$key]['content']=my_substr($noticecontent,50);   
    		$policy[$key]['title']=my_substr($vo['title'],22);
    	}
    	$this->assign('policy',$policy);    	
    	
    	//中间的信息 这个栏目下面的所有的文章 取得前面最新的几条
    	
    	//推荐信息
    	$map3['category_id'] = $list[0]['child'][3]['id'];
		$xinxi = model('Article')->getArticleListBycategoryId($map3,8);
    	foreach ($xinxi as  $key=>$vo){
    		$xinxi[$key]['title']=my_substr($vo['title'],21);
    	}
    	$this->assign('xinxi',$xinxi);
    	
		//招生院校
		
    	
    	//政策信息
    	$map5['category_id'] = $list[0]['child'][4]['id'];
    	$zhengce = model('Article')->getArticleListBycategoryId($map5,9);
    	foreach ($zhengce as  $key=>$vo){
    		$noticecontent = strip_tags($vo['content']);
    		$zhengce[$key]['content']=my_substr($noticecontent,50);
    		$zhengce[$key]['title']=my_substr($vo['title'],28);
    	}
    	$this->assign('zhengce',$zhengce);
    	
    	//招生信息
    	$map6['category_id'] = $list[0]['child'][5]['id'];
    	$zhaosheng = model('Article')->getArticleListBycategoryId($map6,9);
    	foreach ($zhaosheng as  $key=>$vo){
    		$noticecontent = strip_tags($vo['content']);
    		$zhaosheng[$key]['content']=my_substr($noticecontent,50);
    		$zhaosheng[$key]['title']=my_substr($vo['title'],28);
    	}
    	$this->assign('zhaosheng',$zhaosheng);
    	
    	//常见问题
    	$map7['category_id'] = $list[0]['child'][6]['id'];
    	$wenti = model('Article')->getArticleListBycategoryId($map7,9);
    	foreach ($wenti as  $key=>$vo){
    		$noticecontent = strip_tags($vo['content']);
    		$wenti[$key]['content']=my_substr($noticecontent,50);
    		$wenti[$key]['title']=my_substr($vo['title'],28);
    	}
    	$this->assign('wenti',$wenti);
    	
    	//经验交流
    	$map8['category_id'] = $list[0]['child'][7]['id'];
    	$jinyan = model('Article')->getArticleListBycategoryId($map8,9);
    	foreach ($jinyan as  $key=>$vo){
    		$noticecontent = strip_tags($vo['content']);
    		$jinyan[$key]['content']=my_substr($noticecontent,50);
    		$jinyan[$key]['title']=my_substr($vo['title'],28);
    	}
    	$this->assign('jinyan',$jinyan);
    	
    	//试题资讯
    	$map9['category_id'] = $list[0]['child'][8]['id'];
    	$shiti = model('Article')->getArticleListBycategoryId($map9,9);
    	foreach ($shiti as  $key=>$vo){
    		$noticecontent = strip_tags($vo['content']);
    		$shiti[$key]['content']=my_substr($noticecontent,50);
    		$shiti[$key]['title']=my_substr($vo['title'],28);
    	}
    	$this->assign('shiti',$shiti);
    	
    	//外省升本
    	$map10['category_id'] = $list[0]['child'][8]['id'];
		$waishen = model('Article')->getArticleListBycategoryId($map10,9);
		dump($waishen);
    	foreach ($waishen as  $key=>$vo){
    		$noticecontent = strip_tags($vo['content']);
    		$waishen[$key]['content']=my_substr($noticecontent,50);
    		$waishen[$key]['title']=my_substr($vo['title'],28);
    	}
    	$this->assign('waishen',$waishen);
    	 */
		//专升本访谈
		

		//推荐阅读--获取当前页面第一篇
		$lists=[
			$list1[4]['id'],
			$list1[5]['id'],
			$list1[6]['id'],
			$list1[7]['id'],
			$list1[8]['id'],
			$list1[9]['id'],
		];
		$tjyd=model('Getitem')->itemOR($lists,1);
		if(empty($tjyd)){
            $tjyd['title']="";
            $tjyd['image']="";
        }else{
            $tjyd=$tjyd[0];
		}
		
		//普通专升本论坛交流
		$ptzsblt=model('Getitem')->item($list1[7]['id'],'10,9');

		//中间第一栏-政策信息前两个
		$mid1=model('Getitem')->item($list1[4]['id'],2);

		//中间第二栏-整个栏目的前16个
		$mid2=model('Getitem')->itemOR($lists,16);

		//推荐信息，暂时就用那个分类id,8篇
		$tjxx=model('Getitem')->item($list1[6]['id'],'20,8');

		//中间招生院校，获取专升本院校栏目的数据
		$zsyx=model('Getyx')->item(1);

		//政策信息，9篇
		$zcxx=model('Getitem')->item($list1[4]['id'],9);

		//招生信息，9篇
		$zsxx=model('Getitem')->item($list1[5]['id'],9);

		//常见问题，9篇
		$cjwt=model('Getitem')->item($list1[6]['id'],9);

		//经验交流，9篇
		$jyjl=model('Getitem')->item($list1[7]['id'],9);

		//试题资料，9篇
		$stzl=model('Getitem')->item($list1[8]['id'],9);

		//外省升本，9篇
		$wssb=model('Getitem')->item($list1[9]['id'],9);

		//普通专升本专业，获取普通专升本专业栏目的数据或者分类，44条，暂时没有进行，
		$ptzsbzy = model('Getyx')->itemzy();

		//专升本访谈，获取访谈栏目的分类,10条
		$zsbft=model('Getitem')->item($list[6]['id'],10);

    	
        //网站域名
        $domain='';
        //试题资料分类id 77 
        //$stzl=db('article')->where('category_id','17')->order('id desc')->limit(9)->select();

        $this->assign([
            'web_title' =>  '湖北普通专升本网提供全日制3+2专升本考试报名信息_湖北专升本网',
            'web_keywords'  =>  '普通专升本，3+2专升本，湖北普通专升本网',
            'web_description'  =>  '湖北普通专升本网提供全日制3+2专升本科目查询，报名时间通知，历年专升本试题下载和统招专升本招生院校动态，都在湖北专升本网普通专升本频道。',
			'domain'    =>  $domain.'/ptzsb',
			'tjyd'		=>	$tjyd,
			'ptzsblt'	=>	$ptzsblt,
			'mid1'		=>	$mid1,
			'mid2'		=>	$mid2,
			'tjxx'		=>	$tjxx,
			'zsyx'		=>	$zsyx,
			'zcxx'		=>	$zcxx,
			'zsxx'		=>	$zsxx,
			'cjwt'		=>	$cjwt,
			'jyjl'		=>	$jyjl,
			'stzl'		=>	$stzl,
			'wssb'		=>	$wssb,
			'ptzsbzy'	=>	$ptzsbzy,
			'zsbft'		=>	$zsbft,
        ]);
        return $this->fetch(); 
    }

 /*    public function article(){
        if(input('?art')){
            $art=input('art');
            $res=db('article')->where('id',$art)->find();
            if($res===NULL)
                return $this->error('文章不存在');
            else{
                $domain='http://www.spe.com';
                $type='普通专升本';
                $laiyuan='湖北专升本网';
                $cate_id=$res['category_id'];
                $cate=db('category')->where('id',$cate_id)->find();
                $cate1=db('category')->where('id',$cate['pid'])->find();


                $this->assign([
                    'domain'            =>  $domain,
                    'domain2'           =>  $domain.'/ptzsb',
                    'd2name'            =>  $type,
                    'domain3'           =>  $domain.'/ptzsb',
                    'd3name'            =>  $cate['name'],
                    'web_title'         =>  $res['title'],
                    'web_keywords'      =>  $res['title'],
                    'web_description'   =>  '重磅消息：武汉市民办教育管理法出台，考生谨慎选择-湖北专升本网普通专升本频道',
                    'art_title'         =>  $res['title'],
                    'art_content'       =>  $res['content'],
                    'art_ctime'          =>  $res['createtime'], 
                    'art_laiyuan'       =>  $laiyuan,
                    'art_author'        =>  $laiyuan,
                    'art_comment'       =>  '0',
                ]);
                $view=$this->addview($art);
                return $this->fetch('./common/article');
            }
        }else{
            return $this->error('页面不存在');
        }
    }
    
    public function addview($id){
        $res=db('article')->where('id',$id)->setInc('views');
        return $res;
    } */

}